﻿using System;
using System.Collections.Generic;
using System.Drawing;
using System.Text;
using Emgu.CV.Structure;
using Emgu.CV;

namespace Domotica.Gazing
{
    public enum EyePosition
    {
        Unknown,
        Left,
        Right
    }

    public class Eye
    {
        public Eye(Rectangle rect, EyePosition position)
        {
            Rectangle = rect;
            Position = position;
        }

        /// <summary>
        /// Bounding rectangle for the object (average rectangle of a group)
        /// </summary>
        public Rectangle Rectangle { get; set; }

        public Rectangle CalculateRectangle()
        {
            return new Rectangle(Rectangle.X + Rectangle.Width / 4, Rectangle.Y + Rectangle.Height / 4, Rectangle.Width / 2, Rectangle.Height / 2);
        }

        public EyePosition Position { get; set; }

        #region "methods"

        public void Draw(Image<Bgr, Byte> image)
        {
            Color color = Color.Gray;
            switch (Position)
            {
                case (EyePosition.Right) :
                    {
                        color = Color.Green;
                        break;
                    }
                case (EyePosition.Left):
                    {
                        color = Color.Yellow;
                        break;
                    }
            }
            image.Draw(Rectangle, new Bgr(color), 2);
        }

        #endregion

        public Image<Gray, byte> GetImage(Image<Gray, byte> image)
        {
            return image.Copy(Rectangle);
        }

        public Image<Bgr, byte> GetImage(Image<Bgr, byte> image)
        {
            return image.Copy(Rectangle);
        }
    }

    public  class EyeList : List<Eye>
    {
        
    }
}
